package cz.najman.emdroid.mappings;

import java.util.HashMap;

import android.net.Uri;
import android.provider.BaseColumns;
import cz.najman.emdroid.provider.EMDroidDataProvider;
import cz.najman.emdroid.provider.Flags;

/**
 * Helper interface containing useful constants for event resource
 * E.g. Name of database columns, CONTENT_URI, etc.
 * @author Lukas Najman
 *
 */
public class Event extends Mappings implements BaseColumns, Flags{
		
	/**
	 * Uri string representing the event resource
	 */
	public static final String URI_STRING_EVENTS = "content://" + EMDroidDataProvider.AUTHORITY + "/events";	
	
	public static final String URI_STRING_EVENTS_REGISTERED = "content://" + EMDroidDataProvider.AUTHORITY + "/events/registered";	
	
	public static final String URI_STRING_EVENTS_AVAILABLE = "content://" + EMDroidDataProvider.AUTHORITY + "/events/available";
	
	public static final String URI_STRING_EVENTS_MANAGEABLE = "content://" + EMDroidDataProvider.AUTHORITY + "/events/manageable";
	
	/**
	 * Uri representing the event resource
	 */
	
	public static final Uri CONTENT_URI_EVENTS = Uri.parse(URI_STRING_EVENTS);
	
	public static final Uri CONTENT_URI_EVENTS_REGISTERED = Uri.parse(URI_STRING_EVENTS_REGISTERED);
	
	public static final Uri CONTENT_URI_EVENTS_AVAILABLE = Uri.parse(URI_STRING_EVENTS_AVAILABLE);
	
	public static final Uri CONTENT_URI_EVENTS_MANAGEABLE = Uri.parse(URI_STRING_EVENTS_MANAGEABLE);
	
	/**
	 * Content type dir
	 */
	public static final String CONTENT_TYPE_DIR = "vnd.android.cursor.dir/vnd.mitch.event";
	/**
	 * Content type item
	 */
	public static final String CONTENT_TYPE_ITEM = "vnd.android.cursor.item/vnd.mitch.event";
	
	/**
	 * Name of the table in the database
	 */
	public static final String TABLE_NAME = "events";
	
	
	// DB COLUMNS	
	/**
	 * Unique id for the Event
	 */
	//public static final String _ID = "event_id";
	/**
	 * Unique name for the Event
	 */
	public static final String EVENT_NAME = "event_name";
	
	/**
	 * Date of the registration start
	 */
	public static final String REGISTRATION_START = "registration_start"; 
	
	/**
	 * Date of the registration end
	 */
	public static final String REGISTRATION_END = "registration_end";
	
	/**
	 * Date of the Event start
	 */
	public static final String START_DATE = "start_date";
	
	/**
	 * Date of the Event end
	 */
	public static final String END_DATE = "end_date";
	
	/**
	 * Signals if the event is publicly visible
	 */
	public static final String VISIBLE = "visible";
	
	/* DATABASE COLUMNS INDEXES */
	
	public static final int INDEX_ID = 0;
	public static final int INDEX_NAME = 2;
	public static final int INDEX_REGISTRATION_START = 3;
	public static final int INDEX_REGISTRATION_END = 4;
	public static final int INDEX_START_DATE = 5;
	public static final int INDEX_END_DATE = 6;
	public static final int INDEX_VISIBLE = 7;
	public static final int INDEX_STATE_FLAG = 8;	
	
	public static final String URI_TEMPLATE_STRING = "{event_id}";
		
	/* MAPPING KEYS */	
	private static final String M_KEY_START_TAG = "event";
	private static final String M_KEY_ID = "id";
	private static final String M_KEY_EVENT_NAME = "eventName";
	private static final String M_KEY_REGISTRATION_START = "registrationStart";
	private static final String M_KEY_REGISTRATION_END = "registrationEnd";
	private static final String M_KEY_START_DATE = "startDate";
	private static final String M_KEY_END_DATE = "endDate";
	private static final String M_KEY_VISIBLE = "visible";	
			
	public Event() {
		mToDbMappings.put(M_KEY_START_TAG, START_TAG);
		mToDbMappings.put(M_KEY_ID, _ID);
		mToDbMappings.put(M_KEY_EVENT_NAME,EVENT_NAME);
		mToDbMappings.put(M_KEY_REGISTRATION_START,REGISTRATION_START);
		mToDbMappings.put(M_KEY_REGISTRATION_END,REGISTRATION_END);
		mToDbMappings.put(M_KEY_START_DATE,START_DATE);
		mToDbMappings.put(M_KEY_END_DATE,END_DATE);
		mToDbMappings.put(M_KEY_VISIBLE,VISIBLE);	
		
		mDates.add(REGISTRATION_END);
		mDates.add(REGISTRATION_START);
		mDates.add(START_DATE);
		mDates.add(END_DATE);
	}	
	
}

